<template>
    <el-form :inline="true" :model="formData" class="demo-form-inline">
      <el-form-item>
            <el-input v-model="formData.orderId" placeholder="订单id" ></el-input>
        </el-form-item>
        <el-form-item>
            <el-input v-model="formData.memberId" placeholder="用户id" ></el-input>
        </el-form-item>
        <el-form-item>
            <el-input v-model="formData.addressId" placeholder="地址" ></el-input>
        </el-form-item>
        <!-- 摘要输入框 -->
        <el-form-item>
            <el-input v-model="formData.brief" placeholder="备注"></el-input>
        </el-form-item>
    </el-form>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column fixed prop="orderId" label="id" width="150" />
    <el-table-column prop="memberId" label="Name" width="120" />
    <el-table-column prop="status" label="日期" width="120" />
    <el-table-column prop="addressId" label="总价" width="120" />
    <el-table-column prop="needPay" label="备注" width="120" />
    <el-table-column prop="brief" label="更新人" width="120" />
    <el-table-column prop="createTime" label="更新时间" width="120" />
    <el-table-column prop="batchId" label="更新时间" width="120" />
    <el-table-column fixed="right" label="Operations" min-width="140">
      <template #default="scope">
        <el-button type="primary" size="small" @click="out(scope.row)">出库</el-button>
      </template>
    </el-table-column>
  </el-table>
  <el-pagination background layout="total, prev, pager, next" :total="pageData.total" :page-size="pageData.pageSize"
    @current-change="pageChange">
  </el-pagination>
</template>

<script lang="ts" setup>
import { ref, reactive, onMounted } from 'vue'
import { orderApi } from '@/api';
import { useRouter } from 'vue-router'
const formData = reactive({
  orderId: '',
  memberId: '',
  addressId: '',
  brief: ''
})
const pageData = reactive({
  total: 0,
  pageSize: 5,
  pageNum: 1

})
const router = useRouter()
const tableData = ref([])

const out = (row: any) => {
  router.push({ name: 'oo.add', query: { orderId: row.orderId } })
}
const pageChange = (pageNum: number) => {
  pageData.pageNum = pageNum
  callApi()
}

const callApi = () => {
  let params = {
    pageNum: pageData.pageNum,
    pageSize: pageData.pageSize,
    orderId: formData.orderId == "" ? undefined : formData.orderId,
  }

  orderApi.select.call(params).then(res => {

    pageData.total = res.count
    tableData.value = res.items
    console.log(res)
  })
}



onMounted(() => {
  callApi()

})

</script>